﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Runtime.InteropServices;

namespace TestProject1 {
    [TestClass]
    public class TestUnSafe {

        [TestMethod]
        public void TestFixed() {
            A a = new A();
            a.a = 64;
            a.obj = a;
            a.GetType().GetField("obj").GetValue(a);
            
            Console.WriteLine(Marshal.SizeOf(a));
            unsafe {
                fixed(int* ptr = &a.a) {
                    Console.WriteLine(*ptr);
                    Console.WriteLine(*(ptr + 1));
                    Console.WriteLine(*(ptr + 3));
                }
            }
        }


        private class A {
            public int a = 5555;
            public int b = 6666;
            public A obj;
        }
    }
}
